<?php

// http://hi.baidu.com/yangjifu/blog/item/f7c058953a9c1f017af480d3.html

class word
{
	function start()
	{
		ob_start();
		print'<html xmlns="urn:schemas-microsoft-comfficeffice" xmlns:w="urn:schemas-microsoft-comffice:word" xmlns="http://www.w3.org/TR/REC-html40">';
	}

	function save($path)
	{
		print "</html>";
		$data = ob_get_contents();
		ob_end_clean();
		$this->wirtefile ($path,$data);
	}

	function wirtefile($fn,$data)
	{
		$fp=fopen($fn,"wb");
		fwrite($fp,$data);
		fclose($fp);
	}
}

/*演示*/
$word =new word();
$word->start(); // 开始输出
echo 1;
$word->save("data.doc");//保存word并且结束.
?>
